﻿@{
    ViewBag.Title = "Index";
}
<script type="text/javascript" src="/scripts/jquery.js"></script>
<p>
    关键字：@foreach (var item in ViewBag.Keywords)
        {
        <input type="checkbox" name="chb_keyword" value="@item.ID" @(ViewBag.chb_keyword.Contains(item.ID.ToString()) ? "checked='checked'" : "") id="chb_keyword_@item.ID"/><label for="chb_keyword_@item.ID">@item.Keyword</label>
        }
    <input type="checkbox" id="chb_all" /><label for="chb_all">全部</label>
    <script type="text/javascript">
        $("#chb_all").click(function () {
            if (this.checked) {
                $("input[name='chb_keyword']:checkbox").each(function () { //遍历所有的name为selectFlag的 checkbox  
                    $(this).attr("checked", true);
                })
            } else {   //反之 取消全选   
                $("input[name='chb_keyword']:checkbox").each(function () { //遍历所有的name为selectFlag的 checkbox  
                    $(this).attr("checked", false);
                    //alert("f");  
                })
            }
        })
    </script>
</p>
<p>
    类别:<select name="txt_typeid">
        <option value="-1" @(ViewBag.typeid == -1 ? "selected='selected'" : "")>全部</option>
        <option value="1" @(ViewBag.typeid == 1 ? "selected='selected'" : "")>公告</option>
        <option value="0" @(ViewBag.typeid == 0 ? "selected='selected'" : "")>非公告</option>
    </select>
</p>
<p>公司代码:<input type="text" name="txt_code" value="@ViewBag.txt_code" /></p>
<p>
    时间:<select name="txt_days">
        <option value="1" @(ViewBag.days == 1 ? "selected='selected'" : "")>最近一天</option>
        <option value="2" @(ViewBag.days == 2 ? "selected='selected'" : "")>最近二天</option>
        <option value="3" @(ViewBag.days == 3 ? "selected='selected'" : "")>最近三天</option>
        <option value="7" @(ViewBag.days == 7 ? "selected='selected'" : "")>最近一周</option>
        <option value="30" @(ViewBag.days == 30 ? "selected='selected'" : "")>最近一月</option>
    </select>
</p>
<p>标题:<input type="text" name="txt_searchValue" value="@ViewBag.txt_searchValue" /></p>
<p>
    <input type="button" value="查询（不支持回车哦）" id="btn_search" onclick="location.href = '/ann/index?' + $('input,select').serialize()" />
</p>

<table>
    <tr>
        <td style="width: 96px">公司名</td>
        <td style="width: 80px">公司代码</td>
        <td>标题</td>
        <td style="width: 180px">发布时间</td>
    </tr>
    @foreach (var item in ViewBag.AnnList)
    {
        <tr>
            <td><a href="@string.Format("http://f10.eastmoney.com/f10_v2/OperationsRequired.aspx?code=sh{0}", item.secCode)" target="_blank">@item.secName</a>

            </td>
            <td>@item.secCode</td>
            <td>
                @{
        List<WZ.Entity.dic_AnnouncementKeyword> c = ((List<WZ.Entity.dic_AnnouncementKeyword>)ViewBag.Keywords).FindAll(a => ((WZ.Entity.Announcement)item).announcementTitle.Contains(a.Keyword));
        string newTitle = item.announcementTitle;
        if (c.Count > 0)
        {
            foreach (var i in c)
            {
                newTitle = newTitle.Replace(i.Keyword, "<b style='color:red'>" + i.Keyword + "</b>");
            }
        }
                    <a href="@item.adjunctUrl" target="_blank">@(new HtmlString(newTitle))</a>
        
                }
            </td>
            @*<td>@item.announcementTitle</td>*@
            <td>@item.AnnouncementdateTime.ToString("yyyy-MM-dd HH:mm")</td>
        </tr>
        <tr>
            <td colspan="4" style="color: #808080">
                @{
        string cName = string.Empty;
        string iName = string.Empty;
        string aName = string.Empty;
        List<WZ.Entity.dic_CompanyClass> dic = (new WZ.Stock.Data.dic_CompanyClassDAL().GetClassByCompanyCode(item.secCode));
        dic.FindAll(a => a.TypeName.Trim() == "industry").ForEach(i1 => iName += string.Format("[{0}]", i1.Title));
        dic.FindAll(a => a.TypeName.Trim() == "class").ForEach(c1 => cName += string.Format("[{0}]", c1.Title));
        dic.FindAll(a => a.TypeName.Trim() == "area").ForEach(a1 => aName += string.Format("[{0}]", a1.Title));
                    <span>行业：@(new HtmlString(string.IsNullOrWhiteSpace(iName) ? "--" : iName))</span>
                    <span>概念：@(new HtmlString(string.IsNullOrWhiteSpace(cName) ? "--" : cName))</span>
                    <span>地区：@(new HtmlString(string.IsNullOrWhiteSpace(aName) ? "--" : aName))</span>
                }
            </td>
        </tr>
    }

</table>
<hr />
<p>
    我要抓<select name="txt_getdays" id="txt_getdays">
        <option value="0">最近一天</option>
        <option value="1">最近二天</option>
        <option value="2">最近三天</option>
        <option value="6">最近一周</option>
        <option value="29">最近一月</option>
    </select>的数据，<input type="button" value="GO!" id="btn_getdata" onclick="getdata()" />

</p>
<div id="div_log" style="display: none">

    <p>
        <textarea rows="20" cols="100" id="ta_log"></textarea>
    </p>
</div>
<script type="text/javascript">
    function getdata() {
        $("#btn_getdata").val("正在努力抓取...");
        $("#btn_search").attr("disabled", true);
        $("#btn_getdata").attr("disabled", true);
        $.ajax({
            dataType: "json",
            url: "/Ann/GetAnnouncement",
            type: "POST",
            data: { "d": $("#txt_getdays").val() },
            success: function (d) {
                $("#ta_log").val(d.log);
                $("#btn_search").attr("disabled", false);
                $("#btn_getdata").attr("disabled", false);
                $("#btn_getdata").val("抓取完成,共筛选了" + d.totalRecord + "条数据，入库:" + d.totalSuccessRecord + "条");
                $("#div_log").show();
            }
        });
    }
</script>
